clear

%
% Impact of Competition on Technology Adoption
%
% This program creates the figure visually describing the model
% equilibrium
%

pos = get(gca,'Position');
set(gca,'Position',[pos(1) 0.2, pos(3), 0.65]);

Xt = 1:1:14;

% Consumers' budget distribution
x = (0.001:0.001:0.999)';
tmp_dnsty = pdf('Beta',x, 0.697482, 1.71831);
cnsm_dnst = (tmp_dnsty*8.94861+1);
cnsm_bdgt = (x*8.94861+1);

plot(cnsm_bdgt,cnsm_dnst,'-');
set(gca,'XTick',Xt);          %Lines up tic marks with labels
axis([ 1 10 0 150]);
box off;

xlabel('Consumer budget','FontSize',12);
ylabel('Density of consumers','FontSize',12);
hold on

% Competition
% Dividing up consumers by purchase decision
% These are sales over the product cycle (from main_prg_competitive,
% used to back out the marginal consumer.
tmp =      [0.46372;
            0.35078;
            0.15427;
            0.031227];

mrkt_shr = flipud(tmp);
        
tmp0 = cumsum(mrkt_shr);
% marginal consumers and their pdf over [0,1]
tmp1 = icdf('Beta',tmp0, 0.697482, 1.71831);
tmp2 = pdf('Beta',tmp1, 0.697482, 1.71831);
% Translating into [a,b] space
mrg_cnsm = tmp1(1:3)*8.94861+1;
mrg_dnst = (tmp2(1:3)*8.94861+1);

line1 = 0:0.001:mrg_dnst(1);
mrk1 = ones(length(line1),1)*mrg_cnsm(1);
plot(mrk1,line1,'--');
t1 = text(1.01,120,'\leftarrow Purchasers of vintage t-3','FontSize',12);
set(t1,'HorizontalAlignment','left','VerticalAlignment','top','Rotation',0);

line2 = 0:0.001:mrg_dnst(2);
mrk2 = ones(length(line2),1)*mrg_cnsm(2);
plot(mrk2,line2,'--');
t2 = text(1.2,40,'\leftarrow Purchasers of vintage t-2','FontSize',12);
set(t2,'HorizontalAlignment','left','VerticalAlignment','top','Rotation',45);

line3 = 0:0.001:mrg_dnst(3);
mrk3 = ones(length(line3),1)*mrg_cnsm(3);
plot(mrk3,line3,'--');
t3 = text(2.5,20,'\leftarrow Purchasers of vintage t-1','FontSize',12);
set(t3,'HorizontalAlignment','left','VerticalAlignment','top','Rotation',45);
t4 = text(7.5,15,'\leftarrow Purchasers of vintage t','FontSize',12);
set(t4,'HorizontalAlignment','left','VerticalAlignment','top','Rotation',45);

annotation('textbox',[0.65 0.65 0.1 0.1], ...
           'String',{' Vintage     Markup  ', ...
                     '      t               10.3 % ', ...
                     '     t-1              2.7 % ', ...
                     '     t-2              0.8 % ', ...
                     '     t-3              0.3 % '}, ...
           'BackgroundColor',[1 1 1], ...
           'FontSize',12, ...
           'LineStyle','none');


hold off
print -dpsc2 cmpt_case.eps      


